package alicuu.main;

import com.alibaba.fastjson.JSONObject;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.Client;
import alicuu.bean.TestInfo;
import alicuu.util.ESClientFactory;
import alicuu.util.Tools;

/**
 * Created by IntelliJ IDEA.
 * User: danny
 * Date: 17/03/02/
 * Time: 16:15
 */
public class GenerateESData {
    public static void main(String[] args) {
        Client client = ESClientFactory.getInstance().getClient();
        for (int i = 0; i <= 9999; i++) {
            TestInfo info = new TestInfo();
            String jsonInfo = JSONObject.toJSONString(info);
            IndexResponse response = client.
                    prepareIndex("dx_warnning", Tools.getRandom(4) + "", Tools.getRandom(9999) + "")
                    .setSource(jsonInfo).get();
            System.out.println(response);
        }
    }
}
